package com.starview.platform.data.type;

@SuppressWarnings("serial")
public class Type extends AbstractType
{
  public Type(String name, Kind kind)
  {
    super(name, kind);
  }

  public Type(String name)
  {
    this(name, Kind.type);
  }

  public int getArity()
  {
    return kind().arity();
  }

  @Override
  public void accept(ITypeVisitor visitor)
  {
    visitor.visitSimpleType(this);
  }

  @Override
  public <T,C> T transform(TypeTransformer<T,C> trans)
  {
    return trans.transformSimpleType(this);
  }

  @Override
  public boolean equals(Object obj)
  {
    if (obj instanceof IType) {
      IType itype = TypeUtils.deRef((IType) obj);
      if (itype instanceof Type) {
        Type type = (Type) itype;

        return type.typeLabel().equals(typeLabel()) && type.kind().equals(kind());
      }
    }
    return false;
  }

  @Override
  public int hashCode()
  {
    return typeLabel().hashCode();
  }
}
